<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>

        let arr = []
        while (arr.length < 5) {
            let age = +prompt(`输入有效年龄${arr}`)
            age > 0 && age < 120 && arr.push(age)
        }

        for (let i = 0; i < arr.length; i++) {
            if (arr[i] >= 18) { console.log(arr[i]) }
        }
        let sun = 0
        for (let i = 0; i < arr.length; i++) {
            sun += arr[i]

        }
        document.write
        alert(`所有人总和为${sun}`)
        sun = sun / 5
        document.write
        alert(`所有人平均为${sun}`)
        max = arr[0]
        for (let i = 0; i < arr.length; i++) {
            if (max < arr[i]) { max = arr[i] }
        }
        document.write
        alert(`最大值为${max}`)

        min = arr[0]
        for (let i = 0; i < arr.length; i++) {
            if (min > arr[i]) { min = arr[i] }
        }
        document.write
        alert(`最小值为${min}`)




    </script>
</body>

</html>